package com.lzzy.blog001;

import com.lzzy.dao.*;
import com.lzzy.model.domain.Article;
import com.lzzy.model.domain.Comment;
import com.lzzy.model.domain.Friends;
import com.lzzy.model.domain.User;
import com.lzzy.service.impl.ArticleServicelmpl;
import com.lzzy.service.impl.CommentServicelmpl;
import com.lzzy.service.impl.FriendsServiceImpl;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;

import java.util.List;

@SpringBootTest
class daotest {
 @Autowired
    private ArticleRepository ArticleRepository;
    @Test
    void contextLoads() {
        int optional =  ArticleRepository.deleteArticle(12);
        System.out.println(optional);
        System.out.println("我成功了");
    }

    @Autowired
    private CommentRepository commentRepository;
    @Test
    void test2(){
        List<Comment> comments=commentRepository.findByArticleId(1);
        System.out.println(comments);
    }

    @Autowired
    private ArticleServicelmpl articleServicelmpl;
    @Test
    void test3(){
        Page<Article> article= articleServicelmpl.pageArticle(0,2);

        System.out.println(article);
        System.out.println("成功了");
    }

    //添加评论，测试成功
    @Autowired
    private CommentServicelmpl commentServicelmpl;

    @Test

    void test4(){
      commentServicelmpl.addComment(1,"小美","你好，我叫小美，你可以加一下我的博客吗");
    }


    @Test
    void test5(){
        articleServicelmpl.addArticle("大师的养生守则","sddd","dddddddddddddddddddddddddd");
    }

   @Test
    void test6(){
       int i= commentRepository.deleteDiscuss(21);
//     Comment comments=commentRepository.getAllByComment(18);
//     System.out.println(comments);
       System.out.println(i);
   }

   //测试友链功能
    @Autowired
    private FriendsRepository friendsRepository;
    @Test
    void test7(){
        List<Friends> a=friendsRepository.findAll();
        System.out.println(a);
    }

    @Autowired
    private FriendsServiceImpl friendsService;
    @Test
    void test8(){
        friendsService.addFriend("测试","2321334@com","salfajslkdf.clafsjd");
    }

    @Test
    void test9(){
       ArticleRepository.updateArticle("修改","","",30);
    }

    @Test
    void  test10(){
        commentRepository.findAll();
    }

    @Autowired
    private UserRepository userRepository;
    @Test
    void test11(){
        List<User> users=userRepository.findAll();
        System.out.println(users.get(1));
    }



}
